package servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

/**
 * 05-ServletContext对象
 * ③获取资源在服务器上的真实磁盘路径(部署路径)
 *
 */
public class Demo07Servlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //E:\workspace\220106\day04\out\artifacts\day04_war_exploded\demo01.html
        String realPath = getServletContext().getRealPath("demo01.html");
        System.out.println("realPath = " + realPath);

        //E:\workspace\220106\day04\out\artifacts\day04_war_exploded\img\girl3.jpg
        String realPath2 = getServletContext().getRealPath("img/girl3.jpg");
        System.out.println("realPath2 = " + realPath2);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
